/**
 * 
 */
package leetCode;

import java.util.HashSet;

/**
 * @author zhong
 *
 */
public class JewelsandStones {
	public int numJewelsInStones(String J, String S) {
		HashSet<Character> jCharacters = new HashSet<>();
		for (int i = 0; i < J.length(); i++) {
			jCharacters.add(J.charAt(i));
		}
		int res = 0;
		for (int i = 0; i < S.length(); i++) {
			if (jCharacters.contains(S.charAt(i))) {
				res++;
			}
		}
		return res;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
